package com.rftennis.service.impl;



import java.util.HashMap;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.rftennis.ao.CartAo;
import com.rftennis.dao.CustomerCartDao;
import com.rftennis.dao.SqlSessionUtil;

import com.rftennis.service.CartService;

public class CartServiceImpl implements CartService{

	@Override
	public void addcart(CartAo e) throws Exception {
		
		try(SqlSession session=SqlSessionUtil.getSession();){
			session.insert(CustomerCartDao.class.getName()+".insert",e);
			session.commit();
			
		}

		
	}

	@Override
	public void deletecart(String id) throws Exception {
		// TODO Auto-generated method stub
			try(SqlSession session=SqlSessionUtil.getSession();){
				session.delete(CustomerCartDao.class.getName()+".delete",id);
				session.commit();
			}
	}

	@Override
	public void updatecart(String id, String amount) throws Exception {
		// TODO Auto-generated method stub
	
			try(SqlSession session=SqlSessionUtil.getSession();){
				Map<String,Object> map=new HashMap<String, Object>();
				map.put("columnName", id);
				map.put("columnValue", amount);
				session.selectOne(CustomerCartDao.class.getName()+".selectOne",map);
				session.commit();
				
			}
			
	}

	@Override
	public void selectcart(String id) throws Exception {
		// TODO Auto-generated method stub
		try(SqlSession session=SqlSessionUtil.getSession();){
			session.selectOne(CustomerCartDao.class.getName()+".select",id);
			session.commit();
			
	}
	
	}
}